
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 01/22/2013 16:26:03
-- Generated from EDMX file: D:\Work\Things Code\360gu\Things\Things.OrderPlan\Models\Models.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Codematic];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[SaleSetSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SaleSetSet];
GO
IF OBJECT_ID(N'[dbo].[OrderPlanSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OrderPlanSet];
GO
IF OBJECT_ID(N'[dbo].[SetParameterSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SetParameterSet];
GO
IF OBJECT_ID(N'[dbo].[OrderPlanDeliverySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OrderPlanDeliverySet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'SaleSetSet'
CREATE TABLE [dbo].[SaleSetSet] (
    [Id] uniqueidentifier  NOT NULL,
    [GoodsId] uniqueidentifier  NOT NULL,
    [Caption] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [DeliveredCount] int  NOT NULL,
    [DeliveredCycle] int  NOT NULL,
    [DeliveredNumber] int  NOT NULL,
    [UnitPrice] float  NOT NULL
);
GO

-- Creating table 'OrderPlanSet'
CREATE TABLE [dbo].[OrderPlanSet] (
    [Id] uniqueidentifier  NOT NULL,
    [DeliveredCount] int  NOT NULL,
    [DeliveredCycle] int  NOT NULL,
    [DeliveredNumber] int  NOT NULL,
    [UnitPrice] float  NOT NULL,
    [GoodsId] uniqueidentifier  NOT NULL,
    [UserName] nvarchar(max)  NOT NULL,
    [CreatedDate] datetime  NOT NULL,
    [IsPaid] bit  NOT NULL,
    [TotalPrice] float  NOT NULL,
    [BuyerName] nvarchar(max)  NOT NULL,
    [BuyerPhone] nvarchar(max)  NOT NULL,
    [BuyerAddress] nvarchar(max)  NOT NULL,
    [FaPiaoXinXi] nvarchar(200)  NULL,
    [OrderPlanNumber] int IDENTITY(1,1) NOT NULL,
    [SaleSetId] uniqueidentifier  NOT NULL,
    [Status] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'SetParameterSet'
CREATE TABLE [dbo].[SetParameterSet] (
    [Id] uniqueidentifier  NOT NULL,
    [P1] decimal(18,0)  NOT NULL,
    [PN] decimal(18,0)  NOT NULL,
    [N] int  NOT NULL,
    [GoodsId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'OrderPlanDeliverySet'
CREATE TABLE [dbo].[OrderPlanDeliverySet] (
    [Id] uniqueidentifier  NOT NULL,
    [KuaiDiGongSi] nvarchar(max)  NOT NULL,
    [KuaiDiDanHao] nvarchar(max)  NOT NULL,
    [SendDate] datetime  NOT NULL,
    [Status] nvarchar(max)  NOT NULL,
    [OrderPlanID] uniqueidentifier  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'SaleSetSet'
ALTER TABLE [dbo].[SaleSetSet]
ADD CONSTRAINT [PK_SaleSetSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OrderPlanSet'
ALTER TABLE [dbo].[OrderPlanSet]
ADD CONSTRAINT [PK_OrderPlanSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'SetParameterSet'
ALTER TABLE [dbo].[SetParameterSet]
ADD CONSTRAINT [PK_SetParameterSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OrderPlanDeliverySet'
ALTER TABLE [dbo].[OrderPlanDeliverySet]
ADD CONSTRAINT [PK_OrderPlanDeliverySet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------